﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data.Object;
using System.ServiceModel;
using System.ComponentModel;
using PJ.Framework.Common;

namespace PJ.Data.Service
{
    [ServiceContract]
    public interface IObjectProvider<T> : IDisposable
        where T : IObjectData
    {
        /// <summary>
        /// Get : Gets the data object from the data source
        /// </summary>
        /// <param name="globalID">Object global ID</param>
        /// <returns>The data object if found or throws an exception</returns>
        [OperationContract]
        T Get(string globalID);

        /// <summary>
        /// Find : Finds the data object from the data source
        /// </summary>
        /// <param name="globalID">Object global ID</param>
        /// <returns>The data object if found or returns null</returns>
        [OperationContract]
        T Find(string globalID);
        
        /// <summary>
        /// Set : Persists the data object in the data source
        /// </summary>
        /// <param name="entity">Object to persist</param>
        [OperationContract]
        void Set(T entity);
        
        /// <summary>
        /// Exist : Checks if the data object exists in the data source
        /// </summary>
        /// <param name="globalID">Object global ID</param>
        /// <returns>true if found in data source else false</returns>
        [OperationContract]
        bool Exist(string globalID);
        
        /// <summary>
        /// Delete : Removes the data object from the data source
        /// </summary>
        /// <param name="globalID">Object global ID</param>
        [OperationContract]
        void Delete(string globalID);

        /// <summary>
        /// CreateNewItem : Creates a new instance of the concrete class
        /// </summary>
        /// <returns>The data object if found or throws an exception</returns>
        IObjectData CreateNewItem();

    }
}
